/**
 * Xi'An AccuRad Healthcare Technology Co.,Ltd.
 * Copyright (c) 2001-2015 All Rights Reserved.
 */
package com.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @className: DynamicDataSource.java
 * @author: weiLong
 * @version: v1.0
 * @date: 2015年12月29日 下午3:41:55
 * @description: // 动态数据源切换
 */
public class DynamicDataSources extends AbstractRoutingDataSource {

	private static final ThreadLocal<String> dataSourceKey = new InheritableThreadLocal<String>();

	public static void setDataSourceKey(String dataSource) {
		dataSourceKey.set(dataSource);
	}

	@Override
	protected Object determineCurrentLookupKey() {
		return dataSourceKey.get();
	}

}
